package com.vrms.app.controller;

import com.vrms.app.aop.SystemControllerLog;
import com.vrms.app.entity.Floor;
import com.vrms.app.service.FloorService;
import com.vrms.app.tools.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("floor")

@CrossOrigin
public class FloorController {
    @Resource
    private FloorService floorService;

    @GetMapping("/listPage")
    @SystemControllerLog(description = "分页查询医生信息")
    public CommonResult listPage(int page, int size, String buildingNo){
        Map<String,Object> map = new HashMap();
        map.put("count",floorService.count(buildingNo));
        map.put("data",floorService.listPage(page,size,buildingNo));
        return CommonResult.success(map);
    }

    @PostMapping("/save")
    @SystemControllerLog(description = "新建楼宇")
    public CommonResult save(@RequestBody Floor floor){
        return CommonResult.success(floorService.save(floor));
    }

    @PostMapping("/remove")
    @SystemControllerLog(description = "根据ID删除楼宇信息")
    public CommonResult remove(int id){
        return CommonResult.success(floorService.remove(id));
    }

    @PostMapping("/list")
    @SystemControllerLog(description = "查询所有楼宇信息")
    public CommonResult list(){
        return CommonResult.success(floorService.list());
    }
}
